package com.huluobo.a2303mdmdemo.demo

import android.content.Context
import android.util.AttributeSet
import android.util.Log
import android.view.MotionEvent
import android.widget.LinearLayout

/**
 *  Created by LC on 2025/9/3.
 *  1.分发 dispatchTouchEvent
 *  2.拦截 onInterceptTouchEvent  只有Layout中才有 View和Activity都没有拦截方法
 *  3.消费 onTouchEvent Activity的消费事件处于整个事件分发机制的末尾,是否消费都没什么意义
 */
class MyLayout(context: Context, attributeSet: AttributeSet) : LinearLayout(context, attributeSet) {
    override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
        Log.e("TagA", "Layout 分发:${ev?.action}")
        return super.dispatchTouchEvent(ev)
    }

    override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean {
        Log.e("TagA", "Layout 拦截::${ev?.action}")
        return true
    }

    override fun onTouchEvent(event: MotionEvent?): Boolean {
        Log.e("TagA", "Layout 消费::${event?.action}")
        return super.onTouchEvent(event)
    }
}